import { createRouter, createWebHistory } from 'vue-router'
import Login from '../views/login/Login.vue'
import Index from '../views/index/Index.vue'
import ip from '../components/ip/ip.vue'
import ProblemIP from '../components/ip/ProblemIP.vue'
import RepairStation from '../components/ip/RepairStation.vue'
import UserList from '../components/user/UserList.vue'
import UserInfo from '../components/user/UserInfo.vue'
import ProductList from '../components/product/ProductList.vue'
import ProductInfo from '../components/product/ProductInfo.vue'
import NodeGroupManager from '@/views/project3/private/NodeGroupManager.vue'
import Dictionary from '../views/project3/dictionary/dictionary.vue'
import DictionaryData from '../views/project3/dictionary/DictionaryData.vue'

const routes = [
  {
    path: '/',
    name: 'login',
    component: Login
  },
  {
    path: '/index',
    name: 'index',
    component: Index,
    children: [
      {
        path: '/project1/home',
        name: 'project1_home',
        component: () => import('../views/project1/Home.vue')
      },
      {
        path: '/project1/ip',
        name: 'project1_ip',
        component: () => import('../views/project1/ip/ip.vue')
      },
      {
        path: '/project1/problemIP',
        name: 'project1/_problemIP',
        component: ProblemIP
      },
      {
        path: '/project1/repairStation',
        name: 'project1_repairStation',
        component: RepairStation
      },
      {
        path: '/project1/user',
        name: 'project1_user',
        component: UserList
      },
      {
        path: '/project1/userInfo',
        name: 'project1_userInfo',
        component: UserInfo
      },
      {
        path: '/project1/product',
        name: 'project1_product',
        component: ProductList
      },
      {
        path: '/project1/productInfo',
        name: 'project1_productInfo',
        component: ProductInfo
      },
      {
        path: '/project1/strategy',
        name: 'project1_strategy',
        component: () => import('../components/strategy/strategy.vue')
      },
      {
        path: '/project1/private',
        name: 'project1_private',
        component: () => import('../components/private/private.vue')
      },
      {
        path: '/project1/project',
        name: 'project1_project',
        component: () => import('../components/project/project.vue')
      },
      // 项目二
      {
        path: '/project2/home',
        name: 'project2_home',
        component: () => import('../views/project1/Home.vue')
      },
      {
        path: '/project2/ip',
        name: 'project2_ip',
        component: () => import('../views/project2/ip/ip.vue')
      },
      {
        path: '/project2/problemIP',
        name: 'project2_problemIP',
        component: () => import('../views/project2/ip/ProblemIP.vue')
      },
      {
        path: '/project2/repairStation',
        name: 'project2_repairStation',
        component: () => import('../views/project2/ip/RepairStation.vue')
      },
      {
        path: '/project2/user',
        name: 'project2_user',
        component: () => import('../views/project2/user/UserList.vue')
      },
      {
        path: '/project2/userInfo',
        name: 'project2_userInfo',
        component: () => import('../views/project2/user/UserInfo.vue')
      },
      {
        path: '/project2/product',
        name: 'project2_product',
        component: () => import('../views/project2/product/ProductList.vue')
      },
      {
        path: '/project2/productInfo',
        name: 'project2_productInfo',
        component: () => import('../views/project2/product/ProductInfo.vue')
      },
      {
        path: '/project2/strategy',
        name: 'project2_strategy',
        component: () => import('../views/project2/strategy/strategy.vue')
      },
      {
        path: '/project2/private',
        name: 'project2_private',
        component: () => import('../views/project2/private/private.vue')
      },
      {
        path: '/project2/project',
        name: 'project2_project',
        component: () => import('../views/project2/project/project.vue')
      },
      {
        path: '/project2/subscription',
        name: 'project2_subscription',
        component: () => import('../views/project2/subscription/subscription.vue')
      },
      {
        path: '/project2/seo',
        name: 'project2_seo',
        component: () => import('../views/project2/seo/seo.vue')
      },
      {
        path: '/project2/payment',
        name: 'project2_payment',
        component: () => import('../views/project2/payment/payment.vue')
      },
      // 项目三
      {
        path: '/project3/home',
        name: 'project3_home',
        component: () => import('../views/project3/Home.vue')
      },
      {
        path: '/project3/ip',
        name: 'project3_ip',
        component: () => import('../views/project3/ip/ip.vue')
      },
      {
        path: '/project3/problemIP',
        name: 'project3_problemIP',
        component: () => import('../views/project3/ip/ProblemIP.vue')
      },
      {
        path: '/project3/repairStation',
        name: 'project3_repairStation',
        component: () => import('../views/project3/ip/RepairStation.vue')
      },
      {
        path: '/project3/user',
        name: 'project3_user',
        component: () => import('../views/project3/user/UserList.vue')
      },
      {
        path: '/project3/userInfo',
        name: 'project3_userInfo',
        component: () => import('../views/project3/user/UserInfo.vue')
      },
      {
        path: '/project3/product',
        name: 'ProductList',
        component: () => import('../views/project3/product/ProductList.vue')
      },
      {
        path: '/project3/productInfo',
        name: 'project3_productInfo',
        component: () => import('../views/project3/product/ProductInfo.vue')
      },
      {
        path: '/project3/strategy',
        name: 'project3_strategy',
        component: () => import('../views/project3/strategy/strategy.vue')
      },
      {
        path: '/project3/private',
        name: 'project3_private',
        component: () => import('../views/project3/private/private.vue')
      },
      {
        path: '/project3/project',
        name: 'project3_project',
        component: () => import('../views/project3/project/project.vue')
      },
      {
        path: '/project3/product/edit/:id',
        name: 'ProductEdit',
        component: () => import('../views/project3/product/ProductEdit.vue'),
        props: true,
      },
      {
        path: '/project3/apikey',
        name: 'project3_apikey',
        component: () => import('../views/project3/ip/AppKey.vue')
      },
      {
        path: '/project3/private/ProtocolPage',
        name: 'project3_private_ProtocolPage',
        component: () => import('../views/project3/private/ProtocolPage.vue')
      },
      {
        path: '/project3/private/node-group-manager',
        name: 'NodeGroupManager',
        component: NodeGroupManager,
      },
      {
        path: '/project3/dictionary',
        name: 'project3_dictionary',
        component: Dictionary
      },
      {
        path: '/project3/dictionary-data/:id',
        name: 'DictionaryData',
        component: DictionaryData,
      },
      {
        path: '/project3/feedback',
        name: 'project3_feedback',
        component: () => import('../views/project3/feedback/feedback.vue'),
      },
      {
        path: '/project3/finance',
        name: 'project3_finance',
        component: () => import('../views/project3/finance/finance.vue'),
      },
    ]
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

// 导航守卫
// router.beforeEach((to, from, next) => {
//   const isLoggedIn = localStorage.getItem('token')

//   if (!isLoggedIn && to.name !== 'login') {
//     next({ name: 'login' });
//   } else {
//     next();
//   }
// })

export default router
